package com.factory.rental.repository;

import com.factory.rental.model.Tenant;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.Pageable;

@Repository
public interface TenantRepository extends JpaRepository<Tenant, Long> {
    Optional<Tenant> findByIdCard(String idCard);
    Optional<Tenant> findByPhone(String phone);
    List<Tenant> findByNameContaining(String name);
    List<Tenant> findByStatus(Tenant.TenantStatus status);
    List<Tenant> findByBlacklisted(boolean blacklisted);
    Page<Tenant> findByNameContainingOrPhoneContainingOrIdCardContaining(String name, String phone, String idCard, Pageable pageable);
    Page<Tenant> findByStatusOrBlacklisted(Tenant.TenantStatus status, boolean blacklisted, Pageable pageable);
}